Open topic with navigation
HOW TO – Create a Subscription for a RESOURCE using Postman
Prerequisite
Before you can create a subscription for a resource using Postman, you must first create a subscription import/export and add a SUBSCRIBE sub-resource to the resources that you want to allow users to subscribe to. Refer to the HOW TO - Implementing the SUBSCRIBE Method in a Resource topic for more information.
Introduction
If a resource implements subscriptions, it is usually implemented by a sub-resource called SUBSCRIBE. In this topic, we will be using a resource called CUSTOMERS in the RWS integration to illustrate the steps necessary to create a subscription.
You will need access to TCL to perform some of the steps below.
Procedure
- The Postman request builder app enables you to create and send any HTTP request in order to create a subscription for a resource. You can download the Postman app from the following link: https://www.getpostman.com.
Postman is an app that works with Google Chrome. You need to have Google Chrome installed on your machine before you download the Postman app.
- Start Google Chrome.
- Navigate to your Chrome apps and click the icon for the Postman app. The Postman app opens.
- Click the Authorization tab if it is not already selected.
- Select Basic Auth from the Type drop-down menu.
- Enter the username and password for your Kourier REST Gateway user account in their respective fields and click the Update Request button. The Headers tab will show a (1) next to it, indicating that an authorization header has been generated.
- Click the Headers tab. The header information appears below.
- Type X-Connectionin the New Key field.
- Enter the name of the database you want to connect to in the Value field for the X-Connection. For this example, we are using the KU2-SANDBOX database.
- Verify that you have access to the RWS_CUSTOMERS resource by performing a GET on that resource. Ensure that the GET HTTP verb from the drop-down list at the top of the Postman window is selected, then copy and past the following link into the Enter Request URL field.
http://greenflash.koretech.com:8082/RWS/CUSTOMERS/102
- Click the Send button to send the GET request to Kourier.
- If you have set up your request headers correctly, you should receive an HTTP response code of 2nn and depending upon the key passed (e.g. 102), you may see data returned. An example output is shown below.
- Enter the URL in Postman for a subscription to the RWS_CUSTOMERS resource. Be sure to include any required parameters. Select the POST HTTP verb from the drop-down list at the top of the Postman window, then copy and paste the following link into the Enter Request URL field.
http://greenflash.koretech.com:8082/RWS/CUSTOMERS/SUBSCRIBE?Location=T1
- Click the Body tab in Postman and select the raw radio button, then paste the information below into the Body window. An example is shown below.
<?xml version="1.0"?>
<Subscription>
<CallbackURL>{%RequestBinURL}</CallbackURL>
<CallbackAuth></CallbackAuth>
<Description>{UserDescription}</Description>
</Subscription>
- Subscriptions require a call back URL. A call back URL is a URL to your endpoint that can process verification requests and update notifications. Connect to https://requestbin.fullcontact.com/ and click the Create a RequestBin button to create your call back URL. An example of a generated call back URL is shown below.
- Copy the contents of the BinURL into your clipboard. Leave this web page open!
- Replace {%RequestBiinURL} in the XML text you entered into the Body window in step 14 with the actual RequestBinURL (from your clipboard). You may also want to change the Description node.
- Click the Send button in Postman. If you setup everything correctly you should see a response similar to the following example.
- Use TCL to navigate to the database you created the subscription on and force a few records into net change using the KCL.SETLOG command:
KCL.SETLOG CUSTOMER SAMPLE 5
- In the Kourier GUI, select Services from the Process menu and run the service associated with your subscriptions by selecting the subscription (e.g. .gwuser_intg_id_resource) and clicking the Run button.
- Click Continue to run the service, then click OK.
- Navigate back to the RequestBin webpage and click the button in the upper right hand side of the page to see the call back payload processed by Kourier. An example output is shown below.
Related Topics:
HOW TO - Implementing the SUBSCRIBE Method in a Resource